﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UltraSystemLib;

namespace LibTest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                using (var writer = new UltraXMLConfigWriter("DetectorConfig.xml", "宽带检测设备配置文档"))
                {
                    if (writer.IsCreated)
                    {
                        writer.WriteDeviceDescription("短波宽带侦察系统", "Detector", "WinForm");
                        writer.WriteStartGroup("SystemConfig", "短宽设备1");
                        writer.WriteConfigFragment(
                            "设备网络地址分配", 
                            new string[]{"NetConfig", "Address", "Ip:Port"},
                            new object[]{ 
                                "Decimator", "192.168.1.200:10001", 
                                "LocalToDecimator", "192.168.1.101:10001",
                                "LocalToReceiver", "192.168.5.100:10001",
                                "LocalToMonitor", "192.168.1.101:10002"});
                        writer.WriteConfigFragment(
                            "系统参数设置",
                            new string[] { "AppConfig", "Paraments", "value" },
                            new object[]{ 
                                "DispalySpectrum", false, 
                                "AutoDetect", true,
                                "FftSize", 65536});
                        writer.WriteEndGroup();

                        writer.WriteStartGroup("SystemConfig", "短宽设备2");
                        writer.WriteConfigFragment(
                            "设备网络地址分配",
                            new string[] { "NetConfig", "Address", "Ip:Port" },
                            new object[]{ 
                                "Decimator", "192.168.1.200:10001", 
                                "LocalToDecimator", "192.168.1.101:10001",
                                "LocalToReceiver", "192.168.5.100:10001",
                                "LocalToMonitor", "192.168.1.101:10002"});
                        writer.WriteConfigFragment(
                            "系统参数设置",
                            new string[] { "AppConfig", "Paraments", "value" },
                            new object[]{ 
                                "DispalySpectrum", false, 
                                "AutoDetect", true,
                                "FftSize", 65536});
                        writer.WriteEndGroup();
                        writer.WriteEndRootElement();
                    }
                }
                using (var reader = new UltraXMLConfigReader("DetectorConfig.xml"))
                {
                    if (reader.IsOpened)
                    {
                        var paraments = reader.ReadGroup("SystemConfig");
                    }
                    
                }
            }
            catch (Exception)
            {
                
                throw;
            }
            
        }
    }
}
